<!-- templates/index.html -->

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="../static/css/style.css">
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <title>人脉工具</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.0/css/all.min.css" />
  <div class="spinner-container" id="spinner-container" style="display: none;">
    <i id="loading-spinner" class="fas fa-spinner fa-spin"></i>
  </div>
  <style>
    :root {
      --primary-color: #7C3AED;
      /* 优雅的紫色 */
      --primary-light: #A78BFA;
      /* 浅紫色 */
      --primary-dark: #6D28D9;
      /* 深紫色 */
      --secondary-color: #F3F4F6;
      /* 浅灰色 */
      --background-color: #F9FAFB;
      /* 背景色 */
      --text-primary: #1F2937;
      /* 主要文字 */
      --text-secondary: #4B5563;
      /* 次要文字 */
      --gradient: linear-gradient(135deg, #7C3AED, #A78BFA);
    }

    body {
      font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      background: linear-gradient(135deg, #F9FAFB, #F3F4F6);
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 2rem;
    }

    .container {
      width: 90%;
      max-width: 800px;
      background: rgba(255, 255, 255, 0.95);
      backdrop-filter: blur(10px);
      box-shadow: 0 20px 40px rgba(124, 58, 237, 0.1);
      border-radius: 24px;
      padding: 3rem;
    }

    h1 {
      color: var(--primary-color);
      font-size: 2.5rem;
      text-align: center;
      margin-bottom: 2rem;
      font-weight: 800;
      letter-spacing: -0.5px;
    }

    #name-form {
      display: flex;
      gap: 1rem;
      margin-bottom: 2rem;
    }

    input[type="text"] {
      flex: 1;
      padding: 1rem 1.5rem;
      border: 2px solid var(--secondary-color);
      border-radius: 12px;
      font-size: 1rem;
      transition: all 0.3s ease;
      background: white;
    }

    input[type="text"]:focus {
      border-color: var(--primary-color);
      box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
      outline: none;
    }

    button {
      background: var(--gradient);
      color: white;
      padding: 1rem 2rem;
      border: none;
      border-radius: 12px;
      font-size: 1rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s ease;
      white-space: nowrap;
    }

    button:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 20px rgba(124, 58, 237, 0.2);
    }

    #result {
      background: white;
      border-radius: 20px;
      padding: 2rem;
      margin-top: 2rem;
      box-shadow: 0 10px 30px rgba(124, 58, 237, 0.05);
    }

    #result h2 {
      color: var(--primary-color);
      font-size: 1.5rem;
      margin: 2rem 0 1rem;
      padding-bottom: 0.5rem;
      border-bottom: 2px solid var(--primary-light);
      font-weight: 600;
    }

    #result h2:first-child {
      margin-top: 0;
    }

    #profile-pic {
      width: 120px;
      height: 120px;
      object-fit: cover;
      border-radius: 50%;
      margin: 0 auto 2rem;
      display: block;
      border: 4px solid var(--primary-light);
      box-shadow: 0 10px 20px rgba(124, 58, 237, 0.1);
    }

    ul {
      list-style: none;
      padding: 0;
      display: grid;
      gap: 1rem;
    }

    ul li {
      padding: 1rem 1.5rem;
      background: var(--secondary-color);
      border-radius: 12px;
      transition: all 0.3s ease;
      line-height: 1.6;
      color: var(--text-secondary);
    }

    ul li:hover {
      background: rgba(124, 58, 237, 0.05);
      transform: translateX(5px);
      border-left: 3px solid var(--primary-color);
    }

    #letter {
      padding: 1.5rem;
      background: rgba(124, 58, 237, 0.05);
      border-radius: 12px;
      border-left: 4px solid var(--primary-color);
      line-height: 1.8;
      color: var(--text-secondary);
    }

    .spinner-container {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(255, 255, 255, 0.9);
      backdrop-filter: blur(5px);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 1000;
    }

    #loading-spinner {
      color: var(--primary-color);
      font-size: 3rem;
      animation: spin 1s linear infinite;
    }

    @keyframes spin {
      to {
        transform: rotate(360deg);
      }
    }

    @media (max-width: 768px) {
      body {
        padding: 1rem;
      }

      .container {
        padding: 1.5rem;
      }

      #name-form {
        flex-direction: column;
      }

      h1 {
        font-size: 2rem;
      }
    }
  </style>
</head>

<body>
  <div class="container">
    <h1>易速鲜花人脉工具</h1>
    <form id="name-form">
      <input type="text" id="flower" name="flower" placeholder="输入一种花（或者其它东西也行）" autocomplete="off">
      <button id="magic-button" type="submit">找到大V</button>
    </form>
    <div id="result">
      <img id="profile-pic" src="C:\Users\杜东阳\Pictures\Saved Pictures\微信图片_20230324171429.jpg" alt="Profile Picture"
        style="display: none;">
      <h2>基本情况</h2>
      <p id="summary"></p>
      <h2>特色内容</h2>
      <div id="facts"></div>
      <h2>可能感兴趣的事儿</h2>
      <div id="interest"></div>
      <h2>联络邮件</h2>
      <div id="letter"></div>
    </div>
  </div>
  <script>
    $(document).ready(function () {
      $('#name-form').on('submit', function (e) {
        e.preventDefault();
        $('#spinner-container').show();
        $.ajax({
          url: '/process',
          data: $('#name-form').serialize(),
          type: 'POST',
          success: function (response) {
            $('#profile-pic').attr('src', 'C:/Users/杜东阳/Pictures/Saved Pictures/微信图片_20230324171429.jpg');
            $('#profile-pic').show();
            $('#summary').text(response.summary);
            $('#facts').html('<ul>' + response.facts.map(fact => '<li>' + fact + '</li>').join('') + '</ul>');
            $('#interest').html('<ul>' + response.interest.map(interest => '<li>' + interest + '</li>').join('') + '</ul>');
            $('#letter').text(response.letter);
          },
          error: function (error) {
            console.log(error);
          },
          complete: function () {
            $('#spinner-container').hide();
          }
        });
      });
    });
  </script>
</body>

</html>